<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../../resource/dhtmlxsuitev508proeval/skins/skyblue/dhtmlx.css">
    <script src="../../resource/dhtmlxsuitev508proeval/codebase/dhtmlx.js"></script>
    <script src="../../js/jquery-3.4.1.js"></script>
</head>
<body>
<div class="grid_4">
    <div class="selectDiv">
        <div id="medicalType"></div>
    </div>
    <div>
        <div id="combo1"></div>
        <input type="text" id="combo2" />
    </div>
</div>
<script type="text/javascript">

    var medicalTypeCombo;
    var combo1;

    $(function () {
        medicalTypeCombo = new dhtmlXCombo("medicalType", "combo", 150);
        medicalTypeCombo.addOption("s1", "1")
        medicalTypeCombo.addOption("s2", "2")
        medicalTypeCombo.addOption([
            {value: "s11", text: "11"},
            {value: "s13", text: "阿松大"},
            {value: "s14", text: "方法为"},
            {value: "s15", text: "阿特"},
            {value: "s12", text: "错误"}
        ]);
        medicalTypeCombo.attachEvent("onKeyPressed", function (keyCode) {
            let text = medicalTypeCombo.getComboText();
            if (keyCode == "13") {
                medicalTypeCombo.filter(function (opt) {
                    console.log(111, opt);
                    // return opt.text.match(new RegExp(text.toLowerCase(), "i")) != null;
                    return opt.text.indexOf(text) !== -1;
                }, false);
                medicalTypeCombo.openSelect();
            }
        })

        combo1 = new dhtmlXCombo("combo1", "combo", 150);
        combo1.addOption("s1", "1")
        combo1.addOption("s2", "2")
        combo1.attachEvent("onChange", function (value, text) {
            $('#combo2').val(value);
        });

        /*combo1.DOMelem_input.onkeyup = function (ev) {
            if (ev.keyCode == 13) {
                console.log(combo1.getComboText(), combo1.getActualValue());
                combo1.setComboText("");
            }
        }*/

        /*combo1.attachEvent("onBlur", function(){
            combo1.setComboText("");
        });*/

        combo1.attachEvent("onKeyPressed", function(keyCode){
            if (keyCode === 13) {
                console.log(combo1.getComboText());
            }
        });

        combo1.attachEvent("onChange", function(value, text){
            console.log(222, value, text);
        });

    })

</script>
</body>
</html>